package com.bilibili.juc.cf.one;

public class ClosureExample {

    private int instanceVariable = 10;

    public void createLambda() {
        int localVariable = 20;

        Runnable runnable = () -> {
            instanceVariable++; // 可以修改实例变量
            // localVariable++; // 编译错误，不能修改局部变量
            System.out.println("Instance Variable: " + instanceVariable);
            System.out.println("Local Variable: " + localVariable);
        };

        runnable.run();
    }

    public static void main(String[] args) {
        ClosureExample example = new ClosureExample();
        example.createLambda();
        example.createLambda();
    }
}
